<?php
/**现金货到自提等异步通知页*/

$out_trade_no = $_POST['order_id'];
$trade_status = $_POST['trade_status'];
$trade_no = $_POST['trade_no'];
$mysign =$_POST['mysign'];
require_once("cod.config.php");

$cod_verify=new CodVerify($cod_config['key']);
$verify_result = $cod_verify->md5Verify($out_trade_no.$trade_status,$mysign);
if ($trade_status=='SUCCESS'&&$verify_result){
	include_once($config['webroot']."/module/payment/includes/payment_class.php");
	$payment= new payment();
	$payment->apply_result($out_trade_no,$trade_no,$trade_status);
	echo "success";		//请不要修改或删除
}else{
	
	////验证失败
    echo "fail";

    //调试用，写文本函数记录程序运行情况是否正常
    //logResult("这里写入想要调试的代码变量值，或其他运行的结果记录");
}
class CodVerify {
	
	var $signKey;
	
	function __construct($signKey){
		$this->signKey=$signKey;
	}
	
	
	
	function md5Verify($prestr, $sign) {
		$prestr = $prestr . $this->signKey;
		$mysgin = md5($prestr);
	
		if($mysgin == $sign) {
			return true;
		}
		else {
			return false;
		}
	}
	
	
}




